import request from '@/utils/request'
import environment from '@/environment'
import storage from "@/utils/storage.js"
import {
	appInfo
} from "@/config.js"

// 登录方法
export function login(account, password, menuCode = "goldenStar2", captchaKey) {
	const data = {
		account,
		password,
		menuCode,
		captchaKey
	}
	let currentEnv = storage.get("env") || appInfo.env;
	return request({
		'url': `${environment[currentEnv]['pms']}/pms/api/v1/pmsUser/login?encryptTwice=true`,
		headers: {
			isToken: false,
			'Access-Control-Allow-Origin': '*',
			'content-type':'application/x-www-form-urlencoded'
		},
		'method': 'post',
		'data': JSON.stringify(data)  
	})
}

// 退出方法
export function logout() {
	let currentEnv = storage.get("env") || appInfo.env
	return request({
		'url': `${environment[currentEnv]['pms']}/logout`,
		'method': 'post'
	})
}

// 版本检测
export function getCurrentVersion() {
	return request({
		'url': 'http://aksu.suzhidong.cn/longnows/huayouapp/version.json',
		'method': 'get'
	})
}